﻿$(function(){
    
    
    $.fn.commNavTabs = function () {
        /* common nav-tabs */
        // comm-tabs, comm-tabs-head, head-item
        // comm-tabs-body, comm-tabs-body, body-item
        this.each(function () {
            var headItems = $(this).find(".head-item");
            var bodyItems = $(this).find(".body-item");
            headItems.on("click", function () {
                var idx = $(this).index();
                var tmpBodyItem = bodyItems.eq(idx);
                $(this).addClass("current").siblings().removeClass("current");
                tmpBodyItem.show().siblings().hide();
            });
        });
    };
    
    $.commNavTabs2 = function (headTitles, bodys, selClass) {
        headTitles.on("click", function (){
            $(this).addClass(selClass).siblings().removeClass(selClass);
            var idx = $(this).index();
            bodys.eq(idx).show().siblings().hide();
        });
    };
    
    // 增加检验逻辑-中国电话号码格式检查;
	if ($.validator) {
		$.validator.addMethod("mobileCHINA", function (phone_number, element) {
			phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
			var reg = /^(((13[0-9]{1})|15[0-9]{1}|18[0-9]{1}|14[0-9]{1}|17[0-9]{1})+[\d]{8})$/;
			return this.optional(element) || reg.test(phone_number);
		}, "Please specify a valid mobile number");
	}

   
    
});